//
//  MQStatus.swift
//  SinaWeiBo
//
//  Created by 毛强 on 16/1/20.
//  Copyright © 2016年 itheima. All rights reserved.
//

import UIKit

class MQStatus: NSObject {
    
    var id: Int64 = 0
    
    var pic_urls:[MQStatusPictureInfo]?
    var text:String?
    var user:MQUser?
    var created_at:String?
    var source:String?
    
    var reposts_count:Int = 0
    var comments_count:Int = 0
    var attitudes_count:Int = 0
    
    var retweeted_status: MQStatus?
    
    init(dict: [String : AnyObject]) {
        super.init()
        setValuesForKeysWithDictionary(dict)
    }
    
    override func setValue(value: AnyObject?, forKey key: String) {
        if key == "user" {
            if let dict = value as? [String:AnyObject]{
                user = MQUser(dict: dict)
            }
            
        }else if key == "retweeted_status" {
            if let dict = value as? [String:AnyObject]{
                retweeted_status = MQStatus(dict: dict)
            }
        }else if key == "pic_urls" {
            
            
            if let dicts = value as? [[String:AnyObject]]{
                pic_urls = [MQStatusPictureInfo]()
                for dict in dicts {
                    let statusPictureInfo = MQStatusPictureInfo(dict: dict)
                    pic_urls?.append(statusPictureInfo)
                }
            }
        }else{
            super.setValue(value, forKey: key)
        }
    }
    
    override func setValue(value: AnyObject?, forUndefinedKey key: String) {
    }
    
    override var description:String{
        let keys = ["pic_urls"]
        return dictionaryWithValuesForKeys(keys).description
    }
}
